import random

# 随机选择恶意客户端id
def compromised_clients(args):
    
    max_num = max(int(args.c_frac * args.num_clients), 1)
    
    tmp_idx = [i for i in range(args.num_clients)]
    
    compromised_idxs = random.sample(tmp_idx, max_num)

    return compromised_idxs

# 随机选择恶意参与方id  -1或者其他
def compromised_participants(args):
    max_num = max(int(args.c_frac * args.num_clients), 1)

    tmp_idx = [i for i in range(-1, args.num_clients)]

    compromised_idxs = random.sample(tmp_idx, max_num + 1)
    if -1 in compromised_idxs:
        compromised_idxs = [-1]
    else:
        compromised_idxs.pop()

    return compromised_idxs